package com.example.demo.config.tool;

/**
 * 将下划线规则的字符串转成驼峰规则的字符串;
 */
public class CamelCase {
    public static String toCamelCase(String s){
        StringBuilder _new = new StringBuilder();
        for (int i = 0;i < s.length();i++){
            char c = s.charAt(i);
            if(c == '_' && i < s.length() - 1 && s.charAt(i+1) >= 'a' && s.charAt(i + 1) <= 'z'){
                 _new.append((char) (s.charAt(i + 1) - 32));
                 i++;
            }else {
                _new.append(c);
            }
        }

        return _new.toString();
    }
}
